<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableProductOrders extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_addresses', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('username',100)->default('')->nullable(false)->comment('用户名称');
            $table->bigInteger('uid')->default(0)->nullable(false)->comment('用户ID');
            $table->tinyInteger('isdefault')->default(0)->nullable(false)->comment('是否默认1代表默认');
            $table->string('contact')->default('')->nullable(false)->comment('联系电话');
            $table->string('address')->default('')->nullable(false)->comment('送货地址');
            $table->timestamps();
        });
        DB::statement("alter table `user_addresses` comment '用户送货地址表' ");

        Schema::create('prod_orders', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('ordersn',50)->default('')->nullable(false)->comment('商品订单编号');
            $table->bigInteger('uid')->default(0)->nullable(false)->comment('用户ID');
            $table->bigInteger('addressid')->default(0)->nullable(false)->comment('地址ID');
            $table->bigInteger('fee')->default(0)->nullable(false)->comment('运费,包邮为0');
            $table->bigInteger('proid')->default(0)->nullable(false)->comment('商品ID');
            $table->bigInteger('proprice')->default(0)->nullable(false)->comment('商品成交价格');
            $table->bigInteger('pronum')->default(0)->nullable(false)->comment('商品购买数量');
            $table->bigInteger('youhui')->default(0)->nullable(false)->comment('订单优惠金额');
            $table->tinyInteger('status')->default(0)->nullable(false)->comment('订单状态 1待付款 2待发货 3待收货 4已完成 5已取消 6已退');
            $table->string('sendno')->default('')->nullable(false)->comment('发货单号');
            $table->string('sendtype')->default('')->nullable(false)->comment('配送方式');
            $table->dateTime('paytime')->comment('支付时间');
            $table->dateTime('recivetime')->comment('收货时间');
            $table->string('remark')->default('')->nullable(false)->comment('订单备注');
            $table->timestamps();
            $table->engine = 'InnoDB';
        });
        DB::statement("alter table `prod_orders` comment '商品订单表' ");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('prod_orders');
        Schema::dropIfExists('user_addresses');
    }
}
